<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>

<body>
  <h1>axions的基础使用</h1>
  <button id="but" type="submit">提交请求</button>
  <script>
    let oBtn = document.getElementById('but')
    oBtn.onclick = async function () {
      let a;
      try {
        //axios默认返回promise的实列 成功则await接收(await接收就是promise实列成功的值) 失败则移交到catch处理
        
        //await 返回的值是promise实列成功的值
        a = await axios({
          //配置对象
          //请求地址
          url: '/user',
          //必填项url 默认get请求
          method: 'get',
          Headers: {},
          //即将与请求一起发送的url参数
          params: {
            userId: "001"
          },
          data: {},
          timeout: 0
        })
        console.log(a.data);
      } catch (e) {
        console.log(e.message);
      }

    }
  </script>
</body>

</html>